<!doctype html>
<html lang="en">
<head>
  	<script >
		var path='${path}';
	</script>
    <meta charset="UTF-8">
    <title>惠生活</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="${resources}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${resources}/plugins/fontAwesome/4.6.3/css/font-awesome.min.css"  type="text/css">
    <link rel="stylesheet" href="${resources}/css/orderPay.css" type="text/css">
        <#include "setwxshare.ftl"/>
</head>
<body style="height: 100%; background-color: #F0EFED;">
    <div id="container">

        <div class="commonHeader">订单支付
            <a href="javascript:history.go(-1);" class="fa fa-chevron-left back"></a>
        </div>

        <div class="content">
            <!--订单信息-->
            <div class="order_info">
                <p><span class="lfloat" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 213px;float: left !important;
                " >${goods.name}</span><span class="rfloat" >${goods.price}元</span></p>
                <div class="count">
                    <span class="lfloat">数量</span>
                    <div class="num-module">
                        <span class="minus enable">-</span>
                      		 <input type="text" value="1" id="amount" readonly>
                        <span class="plus enable">+</span>
                    </div>
                </div>
               <!-- <p><span class="lfloat">小计</span><span class="rfloat sum" id="total">${goods.price}元</span></p> -->
            </div>
         

			 <ul class="list">
                <li>
                    <span>订单总价</span>
                    <span class="textOrange pullRight"><span class="orderPrice">${goods.price}元</span><!--<span class="couponInfo">（使用优惠券抵消3元）</span>--></span>
                </li>
                <li>
                    <p>您绑定的手机号码</p>
                    <p class="bandPhone" href="javascript:void(0)">
					  	<#if member.username == null>
	                      	<span>未绑定</span>
				      		<a class="pullRight bind">绑定新号码 <span class="fa fa-angle-right"></span></a>
						<#else>	
				  			<span>${member.username}</span>
						</#if>
                    </p>
                </li>
               <li>

        	</li>
            </ul>
            <button class="sendBtn">提交订单</button>
        </div>

    </div>
    
    <input type="hidden" value="${member.username}" id="telephone">
</body>
<script src="${resources}/plugins/jquery/2.2.2/jquery.min.js"></script>
<script src="${resources}/js/common.js"></script>
<script src="${resources}/js/voucherMarketOrderCreate.js"></script>
<script type="text/javascript">

    $(".getCoupon").click(function(){
        $(".coupon"). css("display","block");
    })
    $(".confirm").click(function(){
        $(".coupon"). css("display","none");
    })

   
    
    $(".plus").on("click", function () {
        var minus = $(this).siblings(".minus");
        var input = $(this).siblings("input");
        if ($(this).hasClass("enable")) {
            input.val(Number(input.val()) + 1);
            minus.addClass("enable");
        }
        
        var amount = input.val();
        var price = ${goods.price};
        var total =parseFloat(amount*price).toFixed(2);
        $(".orderPrice").html(total+"元");
    });
    
    $(".minus").on("click", function () {
        var input = $(this).siblings("input");
        if(input.val()<=1){
        	return ;
        }
        if ($(this).hasClass("enable")) {
            input.val(Number(input.val()) - 1);
            if (input.val() == 1)
                $(this).removeClass("enable");
        }
        
     	var amount = input.val();
        var price = ${goods.price};
        var total =parseFloat(amount*price).toFixed(2);
        $(".orderPrice").html(total+"元");
    });
    
$(function(){
	//提交订单
	$(".sendBtn").on("click",function(){
		var goodsid = '${goods.id}';
		var amount =$("#amount").val();
 		var telephone = $("#telephone").val();
		var paymode = 1;
		
	  	if(telephone==""){
      		common.alert({content:"请绑定手机号码"});
         	return;
       	} 
    	$.ajax({
    		type:"post",
        	url:path+"/vouchermarket/order/create",
        	data:{
        		goodsid:goodsid,
        		amount:amount,
        		paymode:paymode
        	},
        	success:function(data){
        		if(data.code=='000'){
        			window.location.href=path+"/pay/"+data.result;
        		}else{
        			common.alert({content:data.msg});
        		}
        	}
    	});
    	//---ajax end ---
    	
	});
})

    

</script>
</html>